package cn.tedu.tmall.admin.mall.controller;

import cn.tedu.tmall.admin.mall.pojo.param.CategoryParam;
import cn.tedu.tmall.admin.mall.service.ICategoryService;
import cn.tedu.tmall.common.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@Api(tags = "类别管理相关接口")
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Resource
    private ICategoryService categoryService;


    @ApiOperation("增加类别")
    @PostMapping("add")
    public JsonResult addCategory(@Validated @RequestBody CategoryParam categoryName) {
        log.debug("增加分类接口入参:{}",categoryName);
        categoryService.addCategory(categoryName);
        JsonResult ok = JsonResult.ok();
        log.debug("增加分类接口入参:{},出参:{}",categoryName,ok);
        return ok;
    }
}
